<?php

    #-------------------------------------------------------------#
	# This file is part of the Tekuna MVC Microframework for PHP. #
	# (c) 2009 Niels Jäckel <niels.jaeckel@tekuna.org>            #
	# Please visit http://tekuna.org/ for more information.       #
	#                                                             #
	# This software is licensed under the MIT License. Please     #
	# view the LICENSE file for the full text of this license.    #
    #-------------------------------------------------------------#


	Tekuna :: load('org.tekuna.core.application.TekunaApplicationContext');
	Tekuna :: load('org.tekuna.core.application.DefaultLanguageChooser');
	Tekuna :: load('org.tekuna.test.core.helper.ClientInformationMock');


	class LanguageChooserTest extends AbstractTekunaTestCase {

		public function testLanguageChooser() {

			// build configuration
			$objConfig = new ApplicationConfiguration();

			// build client
			$objClient = new ClientInformationMock();

			// build context
			$objContext = new TekunaApplicationContext();
			$objContext -> setApplicationConfiguration($objConfig);
			$objContext -> setClientInformation($objClient);

			// build language chooser
			$objLanguageChooser = new DefaultLanguageChooser($objContext);

			// test language chooser
			$objConfig -> setLanguages(array('en', 'de'));
			$objClient -> setAcceptedLanguages(array('de', 'en', 'fr'));
			$this -> assertIdentical($objLanguageChooser -> chooseLanguage(), 'de');

			$objConfig -> setLanguages(array('en', 'de'));
			$objClient -> setAcceptedLanguages(array('en', 'de'));
			$this -> assertIdentical($objLanguageChooser -> chooseLanguage(), 'en');

			$objConfig -> setLanguages(array('en', 'de'));
			$objClient -> setAcceptedLanguages(array('fr', 'cz'));
			$this -> assertIdentical($objLanguageChooser -> chooseLanguage(), 'en');
		}
	}



